class AddIndexesTables < ActiveRecord::Migration
  def self.up
    # words table
    add_index(:words, :text, :unique => true)

    # dictionaries table
    add_index(:dictionaries, :dictionary_id, :unique => true)

    # dictionaries table
    add_index(:word_definitions, [:word_id, :dictionary_id])

    # strategies table
    add_index(:strategies, :strategy_id, :unique => true)

    # synonyms table
    add_index(:synonyms, :word_id)

    # antonyms table
    add_index(:antonyms, :word_id)

    # similar_words table
    add_index(:similar_words, :word_id)

    # related_words table
    add_index(:related_words, :word_id)

    # rhymes table
    add_index(:rhymes, :word_id)

    # feature_requests table
    add_index(:feature_requests, :user_id)

    # votes table
    add_index(:votes, [:feature_request_id, :user_id])
  end

  def self.down
    # words table
    remove_index(:words, :text)

    # dictionaries table
    remove_index(:dictionaries, :dictionary_id)

    # dictionaries table
    remove_index(:word_definitions, [:word_id, :dictionary_id])

    # strategies table
    remove_index(:strategies, :strategy_id)

    # synonyms table
    remove_index(:synonyms, :word_id)

    # antonyms table
    remove_index(:antonyms, :word_id)

    # similar_words table
    remove_index(:similar_words, :word_id)

    # related_words table
    remove_index(:related_words, :word_id)

    # rhymes table
    remove_index(:rhymes, :word_id)

    # feature_requests table
    remove_index(:feature_requests, :user_id)

    # votes table
    remove_index(:votes, [:feature_request_id, :user_id])
  end
end
